package com.baosight.sczx.common.zm.cInterface.cs;

import java.util.HashMap;
import java.util.List;

import com.baosight.iplat4j.core.spring.SpringApplicationContext;
import com.baosight.iplat4j.dao.Dao;
import com.baosight.sczx.common.zm.cInterface.CmesConstants;
import com.baosight.sczx.zm.cs.domain.ZMCSSystemSettingCD;

/**
 * 系统设置-生产文档管理
 * <p>Title: SystemSettingCD.java</p>
 * <p>Description: </p>
 * <p>Copyright: Baosight Software LTD.co Copyright (c) 2002</p>
 * <p>Company: Baosight Software</p>
 * @author 严洪浩
 * @version 1.0
 * <pre>Histroy:
 *          2011-1-18 下午07:46:38  严洪浩  Create
 *</pre>
 */
public class SystemSettingCD {
	
	private static Dao dao = (Dao)SpringApplicationContext.getBean("dao");
	private static SystemSettingCD instance = new SystemSettingCD();
	private static ZMCSSystemSettingCD systemSetting;
	
	private SystemSettingCD(){
		initData();//当第一次使用的时候初始化
	}
	
	@SuppressWarnings("unchecked")
	private void initData(){
		List<ZMCSSystemSettingCD> _list = dao.query("ZMCSSystemSettingCD.query", new HashMap<String, String>());
		if(_list.size() < 1) {
			systemSetting = null;
		}
		else {
			systemSetting = _list.get(0);
		}
		CmesConstants.SYSTEMSETTING_CD = 0;
	}
	
	/**
	 * 获得编辑权限过滤；0全部 1部门 2本人
	 * <p>Function: getSystemModel</p>
	 * <p>Description: </p>
	 * <p>return value:String</p>
	 * <p>throws Exception:</p>
	 * <p>History:
	 *    2011-1-18下午07:58:20 严洪浩
	 * </p>
	 *
	 */
	public String getEditLimits(){
		String _temp = new String("0");//默认为 0全部
		if(systemSetting != null) {
			_temp = systemSetting.getFdEditLimits();
		}
		
		return _temp.toString();
	}
	
	/**
	 * 获得浏览权限; 0全部 1部门 2本人
	 * <p>Function: getMiningType</p>
	 * <p>Description: </p>
	 * <p>return value:String</p>
	 * <p>throws Exception:</p>
	 * <p>History:
	 *    2011-1-18下午08:17:55 严洪浩
	 * </p>
	 *
	 */
	public String getBrowseLimits(){
		String _temp = new String("0");//默认为 0全部
		if(systemSetting != null) {
			_temp = systemSetting.getFdBrowseLimits();
		}
		
		return _temp.toString();
	}
	
	/**
	 * 获得目录操作权限; 0全部 1部门 2本人
	 * <p>Function: getSystemName</p>
	 * <p>Description: </p>
	 * <p>return value:String</p>
	 * <p>throws Exception:</p>
	 * <p>History:
	 *    2011-1-18下午08:18:36 严洪浩
	 * </p>
	 *
	 */
	public String getCatalogLimits(){
		String _temp = new String("1");//默认为 1日
		if(systemSetting != null) {
			_temp = systemSetting.getFdCatalogLimits();
		}
		
		return _temp.toString();
	}
	
	/**
	 * 得到对象的唯一句柄
	 * <p>Function: getInstance</p>
	 * <p>Description: </p>
	 * <p>return value:SystemSettingCD</p>
	 * <p>throws Exception:</p>
	 * <p>History:
	 *    2011-1-18下午07:50:20 严洪浩
	 * </p>
	 *
	 */
	public static SystemSettingCD getInstance(){
		if(CmesConstants.SYSTEMSETTING_CD == 1) {
			instance = new SystemSettingCD();
		}
		
		return instance;
	}
}
